# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=raft
pkgver=0.18.1
pkgrel=0
pkgdesc="C implementation of the Raft consensus protocol"
url="https://github.com/canonical/raft"
arch="all"
license="LGPL-3.0-only WITH LGPL-3.0-linking-exception"
makedepends="linux-headers libuv-dev autoconf automake libtool"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/canonical/raft/archive/v$pkgver.tar.gz
	unistd-include.patch
	disable-bind-address-test-segfaulting.patch"

prepare() {
	default_prepare
	autoreconf -i
}

build() {
	./configure \
		--prefix=/usr \
		--without-lz4 \
		--enable-example=no
	make
}

check() {
	make check || {
		cat ./test-suite.log
		return 1
	}
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums="
20588c743195b1d0e3ff3aaba0b8a0e68c23e700ea16410fefad7191c33a623051f669a6d1d9136d7a8c474ac08b75511b4d50862aa836e6e0105e5a72e1c0fb  raft-0.18.1.tar.gz
1e0e82e42fb9a65e6135e47ef17494e40f973c9a1af8aab09ff10fdbee83b55183414ec6938205806a9f954bbefaaa5eee776bbd313072ac7ce0105f18a2be03  unistd-include.patch
b5c6e5a1ae1b6a06005cdbd3d3379e1d0bc6136307578089971f8ac48601958e9d1d31410d26da4cc91206813a56f01ee59fca64cd68e9a37a9921a339b6bf05  disable-bind-address-test-segfaulting.patch
"
